import 'package:dio/dio.dart';
import 'package:flutter_shop/model/home_model.dart';
import 'dart:async';

const homeUrl = "https://file.lifeipt.top/api/home";
Dio dio = Dio();

class HomeDao {
  static Future<HomeModel> getDataList() async {
    final res = await dio.get(homeUrl);
    // print(res);
    if (res.statusCode == 200) {
      var model = HomeModel.fromJson(res.data);
      return model;
    } else {
      throw Exception("获取接口数据失败！");
    }
  }
}

// class HttpUtil {
//   factory HttpUtil() => _httpInstance();
//   static HttpUtil _instance;
//   late Dio _dio;
//   late BaseOptions orgOptin;

//   static HttpUtil _httpInstance() {
//     if (_instance == null) {
//       _instance = HttpUtil._init();
//     }
//     return _instance;
//   }

//   static HttpUtil _init() {
//     orgOptin = BaseOptions(
//         // contentType: ,
//         connectTimeout: 6 * 1000,
//         receiveTimeout: 6 * 1000,
//         baseUrl: "https://file.lifeipt.top/api");
//     _dio = new Dio(orgOptin);
//   }
// }
